package com.jrx.anytxn.transaction.controller.taiAn;

import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.i18n.response.TxnRespResult;
import com.jrx.anytxn.transaction.dto.taiAnBank.*;
import com.jrx.anytxn.transaction.service.ITaiAnBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = "泰安银行相关接口")
@RestController
@RequestMapping(value = "/api/transaction/taiAn")
public class TaiAnBankController {

    private static final Logger logger = LoggerFactory.getLogger(TaiAnBankController.class);

    @Autowired
    private ITaiAnBankService taiAnBankService;

    @ApiOperation(value = "泰安还款历史查询", notes = "泰安还款历史查询API")
    @PostMapping(value = "/repaymentHistoryQuery")
    public TxnRespResult<RepaymentHistoryRes> repaymentHistoryQuery(@Valid @RequestBody RepaymentHistoryReq repaymentHistoryReq) throws TxnException {
        TxnRespResult<RepaymentHistoryRes> result = new TxnRespResult<>();
        logger.debug("泰安还款历史查询开始startTime:{}",result.getStartTime());
        result.getSuccess(taiAnBankService.repaymentHistoryQuery(repaymentHistoryReq));
        logger.debug("泰安还款历史查询结束endTime{}",result.getEndTime());
        return result;
    }

    @ApiOperation(value = "泰安产品查询", notes = "泰安产品查询API")
    @PostMapping(value = "/productDescQuery")
    public TxnRespResult<ProductDescRes> productDescQuery(@Valid @RequestBody ProductDescReq productDescReq) throws TxnException {
        TxnRespResult<ProductDescRes> result = new TxnRespResult<>();
        logger.debug("泰安产品查询开始startTime:{}",result.getStartTime());
        result.getSuccess(taiAnBankService.productDescQuery(productDescReq));
        logger.debug("泰安产品查询结束endTime{}",result.getEndTime());
        return result;
    }

    @ApiOperation(value = "泰安客户财富查询", notes = "泰安客户财富查询API")
    @PostMapping(value = "/wealthOverQuery")
    public TxnRespResult<WealthOverRes> wealthOverQuery(@Valid @RequestBody ProductDescReq productDescReq) throws TxnException {
        TxnRespResult<WealthOverRes> result = new TxnRespResult<>();
        logger.debug("泰安财富查询开始startTime:{}",result.getStartTime());
        result.getSuccess(taiAnBankService.wealthOverQuery(productDescReq));
        logger.debug("泰安财富查询结束endTime{}",result.getEndTime());
        return result;
    }
}